﻿using Minotaur.App.Core.Contrls;
using Minotaur.App.Domains.Dto.Flow;
using System;
using System.Windows;
using System.Windows.Controls;

namespace Minotaur.App.Modules.FlowProcess.Control
{
    /// <summary>
    /// Interaction logic for FlowArrowLineControl
    /// </summary>
    public partial class FlowArrowLinedControl : UserControl
    {
        private readonly FlowArrowLineUits flowArrowLineUits;
        private readonly Canvas ParentCanvas;
        private readonly FlowLineDto flowLineDto; 
        public FlowArrowLinedControl()
        {
            InitializeComponent();
        }

        public FlowArrowLinedControl(Canvas parentCanvas, FlowLineDto flowLineDto, Point startPoint)
        {
            InitializeComponent();
            ParentCanvas = parentCanvas;
            this.flowLineDto = flowLineDto;
            this.DataContext = flowLineDto;
            flowArrowLineUits = new FlowArrowLineUits() { ParentCanvas = parentCanvas, StartId = flowLineDto.StartId.Value, ArrowCanvas = this.ArrowLineCanvas };
            InitLine(startPoint);
        }

        private void InitLine(Point startPoint)
        {
            flowArrowLineUits.NewDrawArrowLine(startPoint);
            this.ParentCanvas.Children.Add(this);
        }
        public void DrawArrow(Point curPoint, double arrowAngle = Math.PI / 12, double arrowLength = 20)
        {
            flowArrowLineUits.DrawArrow(curPoint, arrowAngle, arrowLength);
        }
    }
}
